package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TrentDao;
import com.xy.manage.model.Trent;
import com.xy.manage.service.TrentService;

@Service
@Transactional
public class TrentServiceImpl extends BaseServiceImpl<Trent> implements
		TrentService {
	private TrentDao trentDao;

	public TrentServiceImpl(TrentDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.trentDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return trentDao.checkExist("Trent", paraName, paraValue);
	}

	@Override
	public List<Trent> getTrent(Map<String, Object> map) {
		return trentDao.getTrent(map);
	}
	@Override
	public Pagination getTrentByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return trentDao.getTrentByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Trent save(Trent trent) {
	//	trent.setModtime(new Date());
		if(trent.getRentid()==null){
			//新增
        	return super.save(trent);
		}else{
			//更新
			Trent trent1=trentDao.get(trent.getRentid());
			try {
				BeanUtil.copyNotNullProperties(trent1, trent);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(trent1);
		}
	}
}